(function(w){
    var slide = function(){
        this.init();
        return this;
    }, c,divSit = 0;

    slide.prototype = {
        init: function(){
            c = this;
            this.options = {};
            this.art = $("<article class = 'slide'>");
            $("body").append(this.art);
            this.evt();
        },
        PagePaint: function (data) {
            var html = "<div style='position: relative;left: 0;height: 100%;'><div class='m-slides' id = 'm_slides'>",leftDts = 0;
            data.forEach(function(item){
                html += "<div style='-webkit-transform: translate3d("+leftDts+"%, 0, 0);' class = 'slide-block'><img src = '"+item+"' id = '"+leftDts+"'></div>";
                leftDts += 100;
            });
            html += "</div></div>";
            this.art.html(html);

            //$(".slide-block").width($("#m_slides").width());
            //$("#m_slides").width($("#m_slides").width()*leftDts/100);

            leftDts -= 100;
            for(;leftDts >= 0;leftDts -= 100){
                $("#"+leftDts)[0].style.marginTop = -($("#"+leftDts)[0].offsetHeight/2)+"px";
            }
        },
        evt: function(){
           $(document).on("touchstart",".slide-block",function (e) {
                c.options.x1 = e.touches[0].pageX;
               console.log(c.options.x1);
                //e.preventDefault();
            });
            $(document).on("touchmove",".slide-block",function (e) {
                //e.preventDefault();
                c.options.x2 = e.touches[0].pageX;
                console.log(c.options.x2);
                //c.tar.css({ "-webkit-transform": c.isUse3D(c.params, tar3D), "-webkit-transition": "0ms" });
            });
            $(document).on("touchend",".slide-block",function (e) {
                var d = c.options.x1 - c.options.x2 > 0 ? 'Left' : 'Right',length = 0;
                var isToNext = Math.abs(c.options.x1 - c.options.x2) > $(".slide-block").width() / 5 ? true : false;
                if(isToNext){//&&e.previousSbiling
                    if(d == "Left"&&this.nextSibling){
                        divSit -= 100;
                        length = $(".slide-block").width() - Math.abs(c.options.x1 - c.options.x2);
                        $("#m_slides").css("-webkit-transform","translate3d("+(-length)+"px, 0, 0)");
                    }else if(d == "Right"&&this.previousSibling){
                        divSit += 100;
                        $("#m_slides").css("-webkit-transform","translate3d("+divSit+"%, 0, 0)");
                    }
                }else {
                    $("#m_slides").css("-webkit-transform","translate3d("+(c.options.x1 - c.options.x2)+"px, 0, 0)");
                }
            });
        }

    };
    w.slide = slide;
}(window));

//new slide().evt();